<%@ page contentType="text/html;charset=UTF-8" language="java" %>
    <%@ page import="entity.FeeType" %>
        <%@ page import="dao.FeeTypeDao" %>

            <% int id=Integer.parseInt(request.getParameter("id")); FeeTypeDao feeTypeDao=new FeeTypeDao(); FeeType
                feeType=feeTypeDao.getFeeTypeById(id); %>

                <html>

                <head>
                    <title>编辑费用项目</title>
                    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css"
                        rel="stylesheet">
                    <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.8.1/font/bootstrap-icons.css"
                        rel="stylesheet">
                    <style>
                        body {
                            background-color: #f8f9fa;
                            padding-top: 2rem;
                        }

                        .container {
                            max-width: 800px;
                        }
                    </style>
                </head>

                <body>
                    <div class="container">
                        <h2>编辑费用项目</h2>
                        <form action="${pageContext.request.contextPath}/admin/feeType/update" method="post">
                            <input type="hidden" name="id" value="<%= feeType.getId() %>">

                            <div class="mb-3">
                                <label class="form-label">费用类型名称</label>
                                <input type="text" class="form-control" name="name" value="<%= feeType.getName() %>"
                                    required>
                            </div>

                            <div class="mb-3">
                                <label class="form-label">单价</label>
                                <input type="number" class="form-control" name="price" step="0.01" min="0"
                                    value="<%= feeType.getPrice() %>" required>
                            </div>

                            <div class="mb-3">
                                <label class="form-label">计费单位</label>
                                <input type="text" class="form-control" name="unit" value="<%= feeType.getUnit() %>"
                                    required>
                            </div>

                            <div class="mb-3">
                                <label class="form-label">说明</label>
                                <textarea class="form-control" name="description"
                                    rows="3"><%= feeType.getDescription() %></textarea>
                            </div>

                            <div class="mb-3">
                                <label class="form-label">状态</label>
                                <select class="form-select" name="status">
                                    <option value="1" <%=feeType.getStatus()==1 ? "selected" : "" %>>启用</option>
                                    <option value="0" <%=feeType.getStatus()==0 ? "selected" : "" %>>禁用</option>
                                </select>
                            </div>

                            <button type="submit" class="btn btn-primary">保存修改</button>
                            <a href="feeTypeManage.jsp" class="btn btn-secondary">返回</a>
                        </form>
                    </div>
                </body>

                </html>